package org.third.common.domain;

import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.third.common.domain.entity.KubeBatchJobFrom;
import org.third.common.domain.entity.KubeBatchJobStatus;
import org.third.common.domain.entity.KubeBatchJobType;

@Entity
@Table(name = "k8s_batch_job")
public class KubeBatchJob {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id")
	private Long id;

	@Column(name = "batch_status", nullable = false)
	@Enumerated(EnumType.STRING)
	private KubeBatchJobStatus status;
	
	@Column(name = "batch_type", nullable = false)
	@Enumerated(EnumType.STRING)
	private KubeBatchJobType type;
	
	@Column(name = "batch_request_from", nullable = false)
	@Enumerated(EnumType.STRING)
	private KubeBatchJobFrom request_from;
	
	@Column(name = "start_time", nullable = false, updatable=false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date startTime;
	
	@Column(name = "end_time", nullable = false, updatable=false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date endTime;

	@Column(name = "invalidated_content")
	@Lob
	private String invalidatedContent;
	
	@Column(name = "invalidated_count",  nullable = false)
	private int invalidatedCount;
	
	@OneToMany(cascade=CascadeType.ALL,fetch = FetchType.LAZY, mappedBy="kubeBatchJob")
	private Set<KubeInstance> kubeInstances;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public KubeBatchJobStatus getStatus() {
		return status;
	}

	public void setStatus(KubeBatchJobStatus status) {
		this.status = status;
	}

	public KubeBatchJobType getType() {
		return type;
	}

	public void setType(KubeBatchJobType type) {
		this.type = type;
	}

	public KubeBatchJobFrom getRequest_from() {
		return request_from;
	}

	public void setRequest_from(KubeBatchJobFrom request_from) {
		this.request_from = request_from;
	}

	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	public Set<KubeInstance> getKubeInstances() {
		return kubeInstances;
	}

	public void setKubeInstances(Set<KubeInstance> kubeInstances) {
		this.kubeInstances = kubeInstances;
	}

	public String getInvalidatedContent() {
		return invalidatedContent;
	}

	public void setInvalidatedContent(String invalidatedContent) {
		this.invalidatedContent = invalidatedContent;
	}

	public int getInvalidatedCount() {
		return invalidatedCount;
	}

	public void setInvalidatedCount(int invalidatedCount) {
		this.invalidatedCount = invalidatedCount;
	}
	
}